home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / tlx_sq21.zip / UPLOAD.SLT < prev    next >
Text File  |  1992-03-20  |  34KB  |  964 lines

  1. //-----------------------------------------------------------
  2. // UPLOAD.SL? Automatic upload to BBSystems.
  3.  
  4. str DIR [6] = "CAT";     // Upload log subdirectory.
  5.  
  6. //-----------------------------------------------------------
  7. // The file <BBS>.UL must be placed in TELIX's program (main)
  8. // directory. The name <BBS> consists of the first 8 (max.) 
  9. // alphabetic characters of the BBS name.
  10. // The following parameters must be defined in this file:
  11.  
  12. // &:Password for private files (Optional; PCBoard only)
  13. // P:Name for private upload (next file only; MBBS only).
  14. // #:Conference number or name (optional)
  15. // F:Filename to upload.
  16. // D:Description of above file
  17. // D:Description of above file (cont.) 
  18. // D:Description of above file (cont.) 
  19. // #:Conference number or name (optional)
  20. // F:Next file to upload
  21. // D:Description of above file
  22. // D:Description of above file (cont.) 
  23. // D:Description of above file (cont.) 
  24. // etc.
  25.  
  26. // Example:
  27.  
  28. // #:XBOARD
  29. // F:GAME1.ZIP
  30. // D:Child's Play part one
  31. // F:GAME2.ZIP
  32. // D:Child's Play part two
  33. // #:Main
  34. // P:Paul Sharp
  35. // F:TXTFND.ZIP
  36. // D:Text finder program
  37.  
  38. // You may specify as many files as you want. The script attempts
  39. // to upload only the first MAXUP files see the NAME.DAT file).
  40. // The description file is NOT modified (successfully uploaded
  41. // files are NOT deleted from the list). Thus you may run the
  42. // script repeatedly if you want to.
  43.  
  44. // You may also write as many specification lines as you want for
  45. // each file. However, there are a few things you should know:
  46. // PCBoard systems accept several lines for the description,
  47. // but each line is limited to 45 characters.
  48.  
  49. // The files to upload must be found either in the upload or down-
  50. // load directory defined in TELIX. If not, you MUST specify a
  51. // directory path with the filenames. The length of a filename
  52. // must not exceed 12 characters.
  53. // There is no check on the line length, so be aware!
  54.  
  55. // Hint: Define a softkey to start this script.
  56. //-----------------------------------------------------------
  57.  
  58. // If you have suggestions for improving this script, please suggest
  59. // improvements to me via old-fashioned snail-mail to:
  60.  
  61. // Author:  Inge Vabekk
  62. //          Hamangskogen 108
  63. //          N-1300 SANDVIKA
  64. //          NORWAY
  65. //          tel. (472) 546 396
  66.  
  67. str ul_spec    [12]          // Upload specifications.
  68.    ,upload_log [64]          // Name of upload log file.
  69.    ,bbs_type   [24]          // BBS type.
  70.    ,NextConf   [24]          // Next conference.
  71.    ,PrevConf   [24]          // Previous conference.
  72.    ,myprot      [2]          // My protocol.
  73.    ,hisprot     [2]          // His protocol.
  74.    ,input      [80]          // Input line.
  75.    ,file       [64]          // Path and filename.
  76.    ,description[80]          // Description.
  77.    ,username   [80]          // User name.
  78.    ,f0         [64]          // Filename for upload.
  79.    ,f1         [64]          // Next filename.
  80.    ,command    [10]          // Command prompt.
  81.    ,temp        [4]          // Temporary for short strings.
  82.                              // For the Global storage:
  83.    ,global   []="GLOBAL"     // Global script.
  84.    ,join     []="JOINCONF"   // Join Conference script.
  85.    ,PutLine  []="PUTLINE"    // Put Line script.
  86.    ,UpDownF  []="UPDOWNF"    // Upload/Download script.
  87.    ,bbstype  []="BTYPE"      // BBS type.
  88.    ,short    []="SHORT"      // Short BBS name.
  89.    ,Cprot    []="CPROT"      // Current protocol.
  90.    ,Hprot    []="HPROT"      // "His" protocol.
  91.    ,version  []="BBSver"     // PCB version
  92.    ,conf     []="CONF"       // Current conference
  93.    ,ConfList []="CNFLST"     // YES if conference list wanted.
  94.    ,prompt   []="PROMPT"     // Current command prompt.
  95.    ,maxup    []="MAXUP"      // Max no. of files to upload
  96.    ;     
  97.  
  98. int tol = 300      // timeout limit is 30 seconds.
  99.    ,tmark, stat 
  100.    ,infile         // Input file pointer
  101.    ,fstat          // Input file status:
  102.                    //  0: Description in "description"
  103.                    // >0: Length of filename in f0 or f1
  104.                    // <0: EOF read.
  105.    ,infilemenu     // in file menu if TRUE.
  106.    ,dline          // Description line number
  107.    ,pcb, mbbs, rbbs, opus, fido, crcs    // Possible BBS types
  108.    ,BBSver         // BBS version.
  109.    ,switched       // TRUE if conference switched.
  110.    ,max            // max. no. of files to upload.
  111.    ,protocol       // Must be INT!
  112.    ,Enter=13       // Code for CR (Enter).
  113.    ,t1, t2, t3, t4, t5, t6  // For tracking.
  114.    ;
  115.  
  116. //-----------------------------------------------------------
  117. // Upload script is entered here.
  118. //-----------------------------------------------------------
  119.  
  120. main()
  121. {
  122. int d, i, k, l;
  123.  
  124.   entry();                             // Updates colors & status bar. 
  125.  
  126. // Check if online.
  127. //-----------------------------------------------------------
  128.  
  129.   if (!carrier())   
  130.   { tone (150,50);                     // No, failure.
  131.     status_wind ("T²: YOU CAN ONLY UPLOAD IF YOU'RE ONLINE!",20);
  132.     return(-1);
  133.   }
  134.  
  135.   newdir (_telix_dir);                 // Move to TELIX dir.
  136.  
  137. // Find BBS type (Set one logical variable).
  138.  
  139.   read (bbstype,input);                // Get BBS type.
  140.  
  141.   mbbs = pcb = rbbs = opus = fido = crcs = 0;
  142.   if      (input == "MBBS") mbbs = 1;
  143.   else if (input == "PCB" ) pcb  = 1;
  144.   else if (input == "RBBS") rbbs = 1;
  145.   else if (input == "OPUS") opus = 1;
  146.   else if (input == "FIDO") fido = 1;
  147.   else if (input == "CRCS") crcs = 1;
  148.   else                                          
  149.   { wrongBBS(input);                   // Doesn't match script!
  150.     return (-1);
  151.   }
  152.   read (version,temp);
  153.   BBSver = subchr (temp,0);            // Get BBS version
  154.  
  155.   read (short,ul_spec);                // Get the BBS's short name.
  156.   read (prompt,command);               // Get command prompt.
  157.   read (cprot,myprot);                 // Get my and
  158.   protocol = subchr (myprot,0);
  159.   read (hprot,hisprot);                // his protocol character.
  160.   read (conf,PrevConf);                // Get conference.
  161.   if (pcb) NextConf = "Main Board";    // Join Main conference.
  162.  
  163. // Construct name of upload log and upload spec files.
  164. //-----------------------------------------------------------
  165.  
  166.   exec ("CRDIR",DIR);                  // Create directory if necessary.
  167.   upload_log = DIR;                    // Set directory.
  168.   strcat (upload_log,"\");
  169.   strcat (upload_log,ul_spec);         // Add BBS name.
  170.   strcat (ul_spec,".UL");              // Add extension.
  171.  
  172. // Read upload specs.
  173.  
  174.   infile = fopen (ul_spec,"r");        // Read from upload spec.file.
  175.   if (infile==0) goto done;            // No such file!
  176.  
  177. // Start uploading.
  178. //-----------------------------------------------------------
  179.  
  180.   i = fstat = 0;
  181.   read (maxup,temp);
  182.   MAX = stoi (temp);
  183.   while (i < MAX && carrier())         // Upload files            
  184.   { while (!fstat)                     // Make sure a filename has
  185.       filename();                      // been read.
  186.     if (UL()) ++i;                     // If upload OK, count file.
  187.     if (fstat<0) i = MAX;              // Quit if EOF read.
  188.   }
  189.   fclose (infile);                     // Close the specification file.
  190.  
  191. done:
  192.   if (!carrier()) return (-1);         // Carrier lost...
  193.   fdelete (ul_spec);                   // Delete the upload file.
  194.  
  195.   if (mbbs && infilemenu)              // In the file menu, MBBS:
  196.   { waitfor (command,2);
  197.     call (PutLine,"Q",Enter);          // Quit.
  198.   }
  199.   else
  200.     flush();
  201.   return (0);
  202. }
  203.  
  204. //-----------------------------------------------------------
  205. // Routine to check if file exists and perform upload.
  206. //-----------------------------------------------------------    
  207.  
  208. // The routine returns zero for unsuccessful, and one for a
  209. // successful upload.
  210. // No message is given for files not found!
  211.  
  212. UL()
  213. {
  214. int ok, error;
  215.  
  216.   if (filename()) return (0);          // Return if no description.
  217.  
  218.   if (strchr(f1,0,'\') > 0)
  219.     file = f1;                         // Directory specified.
  220.   else
  221.   { file = _up_dir;                    // Not s